import Vue from 'vue';
import Router from 'vue-router';
import Home from '../components/common/Home'
import Login from '../components/page/Login'
import ElementUI from 'element-ui';
import { Message, Loading } from 'element-ui'
Vue.use(ElementUI);
// 创建班级路由
import CreateClass from '../components/page/TeachAffairs/ClassAdmin.vue'
// 创建学员管理路由-->添加正式学员
import AddFormaltrainees from '../components/page/Formal/FormalTwo/AddFormaltrainees.vue'
// 创建学员管理路由-->添加意向学员
import AddIntentiontrainees from '../components/page/Formal/FormalTwo/AddIntentiontrainees.vue'
// 编辑正式学员
import FormalcadetsEdit from '../components/page/Formal/FormalTwo/FormalcadetsEdit.vue'
// 班级管理 <--> 创建班级
import AddClass from '../components/page/TeachAffairs/AddClass.vue'
// 班级管理 <--> 创建班级
import RowCourse from '../components/page/TeachAffairs/TeachAffairsTwo/RowCourse.vue'
// 机构管理 <--> 人员管理 <--> 添加人员
import Additions from '../components/page/Mechanism/MechanismTwo/Additions.vue'
// 机构管理 <--> 人员管理 <--> 查看人员
import PersonnelSee from '../components/page/Mechanism/MechanismTwo/PersonnelSee.vue'
// 结算中心 ==> 待结算
import WaitSettlement from '../components/page/Order/OrderTwo/WaitSettlement.vue'
// 结算中心 ==> 待可提现
import Withdrawable from '../components/page/Order/OrderTwo/Withdrawable.vue'

Vue.use(Router);
const router = new Router({
    routes: [
        {
            path: '/',
            component: Login,
        },
        {
            path: '/home',
            component: Home,
            meta: { title: '自述文件' },
            children: [
                {
                    path: '/dashboard',
                    component: () => import('../components/page/Dashboard.vue'),
                    meta: { title: '系统首页' }
                },
                // 班级管理
                {
                    path: '/ClassAdmin',
                    component: () => import('../components/page/TeachAffairs/ClassAdmin.vue'),
                    meta: { title: '班级管理' }
                },
                // 排课管理）——（班级管理
                {
                    path: '/home/ClassAdmin',
                    component: CreateClass,
                    meta: { title: '班级管理' }
                },
                // 班级管理）——（创建班级
                {
                    path: '/AddClass',
                    component: AddClass,
                    meta: { title: '创建班级' }
                },
                // 排课管理
                {
                    path: '/RowcourseAdmin',
                    component: () => import('../components/page/TeachAffairs/RowcourseAdmin.vue'),
                    meta: { title: '排课管理' }
                },
                // 排课管理）——（排课计划
                {
                    path: '/home/RowCourse',
                    component: RowCourse,
                    meta: { title: '排课' }
                },
                // 学员管理
                {
                    path: '/Formalcadets',
                    component: () => import('../components/page/Formal/Formalcadets.vue'),
                    meta: { title: '正式学员' }
                },
                // 学员管理-->添加正式学员
                {
                    path: '/home/AddFormaltrainees',
                    component: AddFormaltrainees,
                    meta: { title: '添加正式学员' }
                },
                // 学员管理-->编辑正式学员
                {
                    path: '/home/FormalcadetsEdit',
                    component: FormalcadetsEdit,
                    meta: { title: '编辑正式学员' }
                },
                // 学员管理-->添加意向学员
                {
                    path: '/home/AddIntentiontrainees',
                    component: AddIntentiontrainees,
                    meta: { title: '添加意向学员' }
                },
                {
                    path: '/IntentionalTrainee',
                    component: () => import('../components/page/Formal/IntentionalTrainee.vue'),
                    meta: { title: '意向学员' }
                },

                // 财务管理
                {
                    path: '/OrderAdmin',
                    component: () => import('../components/page/Order/OrderAdmin.vue'),
                    meta: { title: '订单管理' }
                },

                // 财务管理-->银行账户
                {
                    path: '/Bankaccount',
                    component: () => import('../components/page/Order/Bankaccount.vue'),
                    meta: { title: '银行账户' }
                },
                // 财务管理-->结算中心
                {
                    path: '/Settlement',
                    component: () => import('../components/page/Order/Settlement.vue'),
                    meta: { title: '结算中心' }
                },
                {
                    path: '/home/WaitSettlement',
                    component: WaitSettlement,
                    meta: { title: '待结算' }
                },
                {
                    path: '/home/Withdrawable',
                    component: Withdrawable,
                    meta: { title: '可提现' }
                },
                //商品管理-->折扣设置
                {
                    path: '/Discounts',
                    component: () => import('../components/page/Commodity/Discounts.vue'),
                    meta: { title: '排课管理' }
                },

                // 机构管理-->基础信息
                {
                    path: '/Basicinformation',
                    component: () => import('../components/page/Mechanism/Basicinformation.vue'),
                    meta: { title: '基础信息' }
                },
                // 机构管理-->教室管理
                {
                    path: '/Classroom',
                    component: () => import('../components/page/Mechanism/Classroom.vue'),
                    meta: { title: '教室管理' }
                },
                // 机构管理-->人员管理
                {
                    path: '/Personnel',
                    component: () => import('../components/page/Mechanism/Personnel.vue'),
                    meta: { title: '人员管理' }
                },
                // 机构管理-->人员管理 --> 添加人员
                {
                    path: '/home/Additions',
                    component: Additions,
                    meta: { title: '添加人员' }
                },
                // 机构管理-->人员管理 --> 查看人员
                {
                    path: '/home/PersonnelSee',
                    component: PersonnelSee,
                    meta: { title: '查看人员' }
                },

                // {
                //     path: '/404',
                //     component: resolve => require(['../components/page/404.vue'], resolve),
                //     meta: { title: '404' }
                // },

            ]
        },
        {
            path: '/login',
            component: () => import('../components/page/Login.vue')
        },
        {
            path: '*',
            redirect: '/dashboard'
        }
    ]
})
router.beforeEach((to, from, next) => {
    let organizationinfo = JSON.parse(localStorage.getItem("organizationinfo")) || {};
    let status = organizationinfo.status || 0;
    if (to.path === "/dashboard" || to.path === "/login" || to.path === "/") {
        next();
    } else {
        if (status == 0) {
            Message.warning({ message: '机构被禁用，无法继续使用；如有疑问请联系400-661-0768' });
        } else {
            next();
        }
    }
})
export default router